import pygame

class Block:
    def __init__(self, screen, name = 'block', color=(0,0,0), persition = (0, 0) , size = (1.0, 1.0), data = 100.0, data_end = 100, radius = 0):
        '''
        - 参数:
            - screen: 屏幕
            - name: 名称
            - color: 颜色
            - persion: 位置
            - size: 尺寸
            - data: 数据
            - radius: 圆角半径
        '''
        self.surface = screen
        self.name = name
        self.color = color
        self.x, self.y = persition
        self.width, self.height = size
        self.width_progress = self.width
        self.height_progress = self.height
        self.data = data
        self.data_end = data_end
        self.radius = radius
        
    def draw_block_1(self, surface):
        pygame.draw.rect(surface, (128,128,128), (self.x, self.y, self.width, self.height), border_radius = self.radius)
        pygame.draw.rect(surface, self.color, (self.x, self.y, self.width_progress, self.height), border_radius = self.radius)
        
    def draw_block_2(self, surface):
        #pygame.draw.rect(surface,self.color, (self.x, self.y, self.width, self.height))
        pygame.draw.rect(surface, self.color, (self.x, self.y, self.width, self.height), border_radius=self.radius)
        
    def data_progress(self, data):
        self.data = data
        if self.data  >= 0 and self.data  <= self.data_end :
            self.width_progress = self.width * (self.data / self.data_end)
            
        